﻿using Dyao.Book.Entity;
using Dyao.Book.Repository.Shared;
using Foundation.Core;
using Foundation.Entity;
using Microsoft.EntityFrameworkCore;

namespace Dyao.Book.Repository.DbContext
{
    public class DataModelCreatingHandler : IModelCreatingHandler, ITransientDependency
    {
        public ModelCreatingType CreatingType { get; set; } = ModelCreatingType.Data;

        public void Handle(ModelBuilder modelBuilder)
        {
            var entitiesAssembly = typeof(TestEntity).Assembly;
            modelBuilder.RegisterAllEntities<IEntity>(entitiesAssembly);
            modelBuilder.RegisterEntityTypeConfiguration(this.GetType().Assembly);
        }
    }
}
